package com.lcxw.hxzb.friendcircle.project.system.service.impl;

import java.util.List;

import com.lcxw.hxzb.friendcircle.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lcxw.hxzb.friendcircle.project.system.mapper.YwpdDynamicMapper;
import com.lcxw.hxzb.friendcircle.project.system.domain.YwpdDynamic;
import com.lcxw.hxzb.friendcircle.project.system.service.IYwpdDynamicService;

/**
 * 用户动态Service业务层处理
 *
 * @author jjp
 * @date 2020-07-20
 */
@Service
public class YwpdDynamicServiceImpl implements IYwpdDynamicService {

    @Autowired
    private YwpdDynamicMapper ywpdDynamicMapper;

    /**
     * 查询用户动态
     *
     * @param dynamicId 用户动态ID
     * @return 用户动态
     */
    @Override
    public YwpdDynamic selectYwpdDynamicById(Long dynamicId) {
        return ywpdDynamicMapper.selectYwpdDynamicById(dynamicId);
    }

    /**
     * 查询用户动态列表
     *
     * @param ywpdDynamic 用户动态
     * @return 用户动态
     */
    @Override
    public List<YwpdDynamic> selectDynamicList(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.selectDynamicList(ywpdDynamic);
    }

    /**
     * 新增用户动态
     *
     * @param ywpdDynamic 用户动态
     * @return 结果
     */
    @Override
    public int insertYwpdDynamic(YwpdDynamic ywpdDynamic) {
        ywpdDynamic.setCreateTime(DateUtils.getNowDate());
        ywpdDynamic.setStatus((long) 0);
        ywpdDynamic.setViews((long) 0);
        ywpdDynamic.setLikes((long) 0);
        ywpdDynamic.setComments((long) 0);
        return ywpdDynamicMapper.insertYwpdDynamic(ywpdDynamic);
    }


    /**
     * 对某条动态不感兴趣
     *
     * @param ywpdDynamic 用户动态
     * @return 结果
     */
    @Override
    public int insertYwpdDynamicLose(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.insertYwpdDynamicLose(ywpdDynamic);
    }

    /**
     * 修改用户动态
     *
     * @param ywpdDynamic 用户动态
     * @return 结果
     */
    @Override
    public int updateYwpdDynamic(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.updateYwpdDynamic(ywpdDynamic);
    }

    /**
     * 批量删除用户动态
     *
     * @param dynamicIds 需要删除的用户动态ID
     * @return 结果
     */
    @Override
    public int deleteYwpdDynamicByIds(Long[] dynamicIds) {
        return ywpdDynamicMapper.deleteYwpdDynamicByIds(dynamicIds);
    }

    @Override
    public int deleteDynamicById(Long dynamicId) {
        return ywpdDynamicMapper.deleteDynamicById(dynamicId);
    }

    /**
     * 删除用户动态信息
     *
     * @param dynamicId 用户动态ID
     * @return 结果
     */
    @Override
    public int deleteYwpdDynamicById(Long dynamicId) {
        return ywpdDynamicMapper.deleteYwpdDynamicById(dynamicId);
    }

    // 查询点赞总数
    @Override
    public int querylistsByUser(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.querylistsByUser(ywpdDynamic);
    }

    // 物品    点赞likes + 1
    @Override
    public int insertLikeByUser(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.insertLikeByUser(ywpdDynamic);
    }

    // 物品取消点赞likes - 1
    @Override
    public int deleteLikeByUser(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.deleteLikeByUser(ywpdDynamic);
    }

    @Override
    public int insertCommentsByUser(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.insertCommentsByUser(ywpdDynamic);
    }

    @Override
    public int deleteCommentsByUser(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.deleteCommentsByUser(ywpdDynamic);
    }

    @Override
    public Long queryCommentsByChild(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.queryCommentsByChild(ywpdDynamic);
    }

    @Override
    public int updateViewsByUser(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.updateViewsByUser(ywpdDynamic);
    }

    @Override
    public List<YwpdDynamic> selectFreindList(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.selectFreindList(ywpdDynamic);
    }

    @Override
    public List<YwpdDynamic> selectNearbyList(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.selectNearbyList(ywpdDynamic);
    }

    @Override
    public YwpdDynamic selectDetail(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.selectDetail(ywpdDynamic);
    }

    @Override
    public void insertYwpdDynamicList(List<YwpdDynamic> list) {
        ywpdDynamicMapper.insertYwpdDynamicList(list);
    }

    @Override
    public YwpdDynamic queryAllUser(String userId) {
        return ywpdDynamicMapper.queryAllUser(userId);
    }

    @Override
    public List<YwpdDynamic> queryAllCommentByUserId(YwpdDynamic ywpdDynamic) {
        return ywpdDynamicMapper.queryAllCommentByUserId(ywpdDynamic);
    }
}
